<?php
/**
 * Created by PhpStorm.
 * User: jz
 * Date: 16/7/13
 * Time: 上午10:41
 */
require_once ('bookmark_fns.php');
session_start();

do_html_header('修改密码');

$old = $_POST['old_password'];
$new = $_POST['new_password'];
$new2 = $_POST['new_password2'];

try {
    check_valid_user();
    if (!filled_out($_POST)){
        throw new Exception('您填入的信息不完整');
    }
    if ($new != $new2){
        throw new Exception('两次输入的密码不一致');
    }
    if (strlen($new) > 16 || strlen($new) < 6){
        throw new Exception('密码长度不对');
    }
    change_password($_SESSION['valid_user'], $old, $new);
    echo '密码修改成功';
}catch (Exception $e){
    echo $e->getMessage();
}
display_user_menu();
do_html_footer();